package pl.edu.utp.kursy.database;

import java.util.Date;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "course_events")
public class CourseEvent extends BaseId{
    
    @ManyToOne(fetch = FetchType.EAGER)
    private Course course;
    
    @Column(name = "start_date")
    @Temporal(TemporalType.DATE)
    private Date startDate;
    
    @Column(name = "end_date")
    @Temporal(TemporalType.DATE)
    private Date endDate;
    
    @Column(name = "comments")
    private String comments;
    
    @Column(name = "cost")
    private double cost = 0.0;
    
    @Column(name="vat", nullable = false)
    private int vat = 23;
    
    @ManyToMany(fetch = FetchType.EAGER)
    private Set<Company> companies;
    
    @ManyToMany(fetch = FetchType.EAGER)
    private Set<Worker> workers;
    
    @OneToMany(fetch = FetchType.EAGER, mappedBy = "event",cascade = CascadeType.REMOVE)
    private Set<CourseEventCompanyAccomodation> courseEventsCompanyAccomodation;

    public Course getCourse() {
        return course;
    }

    public void setCourse(Course course) {
        this.course = course;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String getComments() {
        return comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }

    public double getCost() {
        return cost;
    }

    public void setCost(double cost) {
        this.cost = cost;
    }

    public int getVat() {
        return vat;
    }

    public void setVat(int vat) {
        this.vat = vat;
    }
   
    public Set<Company> getCompanies() {
        return companies;
    }

    public void setCompanies(Set<Company> companies) {
        this.companies = companies;
    }

    public Set<Worker> getWorkers() {
        return workers;
    }

    public void setWorkers(Set<Worker> workers) {
        this.workers = workers;
    }

    public Set<CourseEventCompanyAccomodation> getCourseEventsCompanyAccomodation() {
        return courseEventsCompanyAccomodation;
    }

    public void setCourseEventsCompanyAccomodation(Set<CourseEventCompanyAccomodation> courseEventsCompanyAccomodation) {
        this.courseEventsCompanyAccomodation = courseEventsCompanyAccomodation;
    }
    
}
